home *** CD-ROM | disk | FTP | other *** search
/ Nejlepší hry / Nejlepsi hry.iso / hry / sea of chaos / sea_install.msi / _15C39AAA7726369D39812BD40F01CF6A / _13ABB8B056894ECF8D079509399DE5FC < prev    next >
Text File  |  2005-03-23  |  1KB  |  52 lines

  1. //simple shader to clip any pixels with a Z coordinate below the water plane
  2. //does not apply lights
  3. //applies vertex diffuse colors and texture sampling
  4. //must be used with clipZ2.psh
  5. //Luke Lenhart
  6. //(C)2004-2005 Digipen Institute of Technology
  7.  
  8. //world,view,projection transform
  9. float4x4 matWorldViewProj;
  10. float4x4 matWorld;
  11.  
  12. //clip anything below this
  13. float minZ;
  14.  
  15. //shader input
  16. struct VS_INPUT
  17. {
  18.     float4 Pos : POSITION;
  19.     float2 Tex0 : TEXCOORD0;
  20.     float4 Clr : COLOR0;
  21. };
  22.  
  23. //shader output
  24. struct VS_OUTPUT
  25. {
  26.     float4 Pos0 : POSITION;
  27.     float PosZ : TEXCOORD1;
  28.     float2 Tex0 : TEXCOORD0;
  29.     float4 Clr : COLOR0;
  30. };
  31.  
  32. //shader code
  33. VS_OUTPUT VShader(VS_INPUT In)
  34. {
  35.     VS_OUTPUT Out;
  36.     
  37.     //copy tex coord
  38.     Out.Tex0=In.Tex0;
  39.     
  40.     //calc transformed position
  41.     Out.Pos0=mul(matWorldViewProj,In.Pos);
  42.     float4 wPos=mul(matWorld,In.Pos);
  43.     
  44.     Out.PosZ=wPos.z-minZ; //pass through z position with clip position offset
  45.     
  46.     //copy color
  47.     Out.Clr=In.Clr;        
  48.         
  49.     //spit out the results
  50.     return Out;
  51. }
  52.